package com.sc.nft.admin.controller;


import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.MallProfitTemplate;
import com.sc.nft.entity.SysMember;
import com.sc.nft.entity.dto.AdminMallActivitySharePageDTO;
import com.sc.nft.entity.dto.MallActivityShareDetailDTO;
import com.sc.nft.entity.dto.MallProfitTemplateAdminDetailDTO;
import com.sc.nft.entity.dto.MallProfitTemplateAdminPageDTO;
import com.sc.nft.entity.vo.AdminMallActivitySharePageVO;
import com.sc.nft.entity.vo.EditMallActivityShareVO;
import com.sc.nft.entity.vo.EditMallProfitTemplateVO;
import com.sc.nft.entity.vo.MallProfitTemplateAdminPageVO;
import com.sc.nft.pool.SysMemberPool;
import com.sc.nft.service.MallProfitTemplateService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 商城分润模版 前端控制器
 * </p>
 *
 * @author ligen
 * @since 2024-01-09
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/profitTemplate")
@Api(tags = "商城分润模版模块")
public class MallProfitTemplateController {

    public final MallProfitTemplateService mallProfitTemplateService;


    @ApiOperation(value = "商城分润模版列表", notes = "商城分润模版列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    public PageResult<MallProfitTemplateAdminPageDTO> mallProfitTemplateAdminPage(@RequestBody MallProfitTemplateAdminPageVO mallProfitTemplateAdminPageVO) {
        return PageResult.success(mallProfitTemplateService.getAdminPage(mallProfitTemplateAdminPageVO));
    }

    @ApiOperation(value = "商城分润模版详情", notes = "商城分润模版详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/detail", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<MallProfitTemplateAdminDetailDTO> getAdminDetail(@RequestBody IdRequest idRequest) {
        return Result.success(mallProfitTemplateService.getAdminDetail(idRequest.getId()));
    }

    @ApiOperation(value = "编辑商城分润模版", notes = "编辑商城分润模版", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result edit(@Valid @RequestBody EditMallProfitTemplateVO editMallProfitTemplateVO) {
        SysMember member = SysMemberPool.getMember();
        mallProfitTemplateService.edit(member.getId(), editMallProfitTemplateVO);
        return Result.success();
    }

    @ApiOperation(value = "商城分润模版上架", notes = "商城分润模版上架", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/enable", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result enable(@Valid @RequestBody IdRequest idRequest) {
        mallProfitTemplateService.enable(idRequest.getId());
        return Result.success();
    }

    @ApiOperation(value = "商城分润模版上架下架", notes = "商城分润模版上架下架", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/disable", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result disable(@Valid @RequestBody IdRequest idRequest) {
        mallProfitTemplateService.disable(idRequest.getId());
        return Result.success();
    }
}
